package c.e.a.c;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewParent;
import b.b.h.f0;
import b.i.k.o;
import c.e.a.c.t.g;
import c.e.a.c.t.i;
import c.e.b.g.c;
import c.e.b.g.d;
import c.e.b.g.d.b;
import c.e.b.h.e.k.o0;
import c.e.b.h.e.k.p0;
import c.e.b.o.e;
import com.huawei.agconnect.exception.AGCServerException;
import java.util.List;
import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import kotlin.KotlinVersion;

public final class a {
    public static ExecutorService a(String str) {
        ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor(new o0(str, new AtomicLong(1)));
        Runtime.getRuntime().addShutdownHook(new Thread(new p0(str, newSingleThreadExecutor, 2, TimeUnit.SECONDS), c.b.a.a.a.D("Crashlytics Shutdown Hook for ", str)));
        return newSingleThreadExecutor;
    }

    public static d<?> b(String str, String str2) {
        c.e.b.o.a aVar = new c.e.b.o.a(str, str2);
        b a = d.a(e.class);
        a.d = 1;
        a.d(new c(aVar));
        return a.b();
    }

    public static Animator c(c.e.a.c.k.b bVar, float f, float f2, float f3) {
        ObjectAnimator ofObject = ObjectAnimator.ofObject(bVar, c.e.a.c.k.b.c.a, c.e.a.c.k.b.b.b, new c.e.a.c.k.b.e[]{new c.e.a.c.k.b.e(f, f2, f3)});
        c.e.a.c.k.b.e revealInfo = bVar.getRevealInfo();
        if (revealInfo != null) {
            Animator createCircularReveal = ViewAnimationUtils.createCircularReveal((View) bVar, (int) f, (int) f2, revealInfo.c, f3);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(new Animator[]{ofObject, createCircularReveal});
            return animatorSet;
        }
        throw new IllegalStateException("Caller must set a non-null RevealInfo before calling this.");
    }

    public static c.e.a.c.t.d d(int i) {
        if (i == 0) {
            return new i();
        }
        if (i != 1) {
            return new i();
        }
        return new c.e.a.c.t.e();
    }

    public static String e() {
        try {
            return KotlinVersion.CURRENT.toString();
        } catch (NoClassDefFoundError unused) {
            return null;
        }
    }

    public static float f(float f, float f2, float f3, float f4) {
        return (float) Math.hypot((double) (f3 - f), (double) (f4 - f2));
    }

    public static float g(Context context, int i) {
        return TypedValue.applyDimension(1, (float) i, context.getResources().getDisplayMetrics());
    }

    public static int h(Context context, int i, int i2) {
        TypedValue s = s(context, i);
        return s != null ? s.data : i2;
    }

    public static int i(View view, int i) {
        return u(view.getContext(), i, view.getClass().getCanonicalName());
    }

    public static ColorStateList j(Context context, TypedArray typedArray, int i) {
        if (typedArray.hasValue(i)) {
            int resourceId = typedArray.getResourceId(i, 0);
            if (resourceId != 0) {
                ColorStateList a = b.b.d.a.a.a(context, resourceId);
                if (a != null) {
                    return a;
                }
            }
        }
        return typedArray.getColorStateList(i);
    }

    public static ColorStateList k(Context context, f0 f0Var, int i) {
        if (f0Var.b.hasValue(i)) {
            int resourceId = f0Var.b.getResourceId(i, 0);
            if (resourceId != 0) {
                ColorStateList a = b.b.d.a.a.a(context, resourceId);
                if (a != null) {
                    return a;
                }
            }
        }
        return f0Var.c(i);
    }

    public static Drawable l(Context context, TypedArray typedArray, int i) {
        if (typedArray.hasValue(i)) {
            int resourceId = typedArray.getResourceId(i, 0);
            if (resourceId != 0) {
                Drawable b = b.b.d.a.a.b(context, resourceId);
                if (b != null) {
                    return b;
                }
            }
        }
        return typedArray.getDrawable(i);
    }

    public static boolean m(View view) {
        WeakHashMap weakHashMap = o.a;
        return view.getLayoutDirection() == 1;
    }

    public static int n(int i, int i2, float f) {
        return b.i.d.a.a(b.i.d.a.c(i2, Math.round(((float) Color.alpha(i2)) * f)), i);
    }

    public static float o(float f, float f2, float f3) {
        return (f3 * f2) + ((1.0f - f3) * f);
    }

    public static int p(int i) {
        if (i >= AGCServerException.OK && i <= 299) {
            return 0;
        }
        if (i >= 300 && i <= 399) {
            return 1;
        }
        if (i >= AGCServerException.AUTHENTICATION_INVALID && i <= 499) {
            return 0;
        }
        if (i >= AGCServerException.UNKNOW_EXCEPTION) {
        }
        return 1;
    }

    public static Mode q(int i, Mode mode) {
        if (i == 3) {
            return Mode.SRC_OVER;
        }
        if (i == 5) {
            return Mode.SRC_IN;
        }
        if (i == 9) {
            return Mode.SRC_ATOP;
        }
        switch (i) {
            case 14:
                return Mode.MULTIPLY;
            case 15:
                return Mode.SCREEN;
            case 16:
                return Mode.ADD;
            default:
                return mode;
        }
    }

    public static void r(AnimatorSet animatorSet, List<Animator> list) {
        int size = list.size();
        long j = 0;
        for (int i = 0; i < size; i++) {
            Animator animator = (Animator) list.get(i);
            j = Math.max(j, animator.getDuration() + animator.getStartDelay());
        }
        ValueAnimator ofInt = ValueAnimator.ofInt(new int[]{0, 0});
        ofInt.setDuration(j);
        list.add(0, ofInt);
        animatorSet.playTogether(list);
    }

    public static TypedValue s(Context context, int i) {
        TypedValue typedValue = new TypedValue();
        return context.getTheme().resolveAttribute(i, typedValue, true) ? typedValue : null;
    }

    public static boolean t(Context context, int i, boolean z) {
        TypedValue s = s(context, i);
        if (s == null || s.type != 18) {
            return z;
        }
        return s.data != 0;
    }

    public static int u(Context context, int i, String str) {
        TypedValue s = s(context, i);
        if (s != null) {
            return s.data;
        }
        throw new IllegalArgumentException(String.format("%1$s requires a value for the %2$s attribute to be set in your app theme. You can either set the attribute in your theme or update your theme to inherit from Theme.MaterialComponents (or a descendant).", new Object[]{str, context.getResources().getResourceName(i)}));
    }

    public static void v(View view, float f) {
        Drawable background = view.getBackground();
        if (background instanceof g) {
            g gVar = (g) background;
            g.b bVar = gVar.a;
            if (bVar.o != f) {
                bVar.o = f;
                gVar.w();
            }
        }
    }

    public static void w(View view, g gVar) {
        c.e.a.c.m.a aVar = gVar.a.b;
        Object obj = (aVar == null || !aVar.a) ? null : 1;
        if (obj != null) {
            float f = 0.0f;
            for (ViewParent parent = view.getParent(); parent instanceof View; parent = parent.getParent()) {
                View view2 = (View) parent;
                WeakHashMap weakHashMap = o.a;
                f += view2.getElevation();
            }
            g.b bVar = gVar.a;
            if (bVar.n != f) {
                bVar.n = f;
                gVar.w();
            }
        }
    }

    public static PorterDuffColorFilter x(Drawable drawable, ColorStateList colorStateList, Mode mode) {
        return (colorStateList == null || mode == null) ? null : new PorterDuffColorFilter(colorStateList.getColorForState(drawable.getState(), 0), mode);
    }
}
